const path = require('path');
const webpack = require('webpack');

// Plugins
// const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
const Merge = require('webpack-merge');
const CommonConfig = require('./webpack.common.js');

const package = require('../package.json');

module.exports = Merge(CommonConfig, {
    output: {
        filename: 'js/[name].js',
        chunkFilename: 'js/[name].chunk.js'
    },
    plugins: [
        //new BundleAnalyzerPlugin()
        new webpack.DefinePlugin({
            'process.env.NODE_ENV': JSON.stringify('development'),
            'aphf.VERSION': JSON.stringify(package.version),

            // 'aphf.cfg.ADMIN_API_ADDR': JSON.stringify('http://localhost:1297/aphf/v1'),
            // 'aphf.cfg.API_ADDR': JSON.stringify('http://localhost:17443/aphf/v1'),
            // 'aphf.img.ADDR': JSON.stringify('http://localhost:1297/images/'),
            // 'aphf.file.ADDR': JSON.stringify('http://localhost:1297/log/'),
            'aphf.cfg.API_ADDR': JSON.stringify('https://api.aphf2018.cn/aphf/v1'),
            'aphf.cfg.ADMIN_API_ADDR': JSON.stringify('https://admin.aphf2018.cn/api/aphf/v1'),
            'aphf.img.ADDR': JSON.stringify('https://files.aphf2018.cn/images/'),
            'aphf.file.ADDR': JSON.stringify('https://files.aphf2018.cn/files/')
        })
    ],
    resolve: {
        alias: {
            'vue': 'vue/dist/vue.esm',
        }
    },
    devtool: 'eval-source-map',
    devServer: {
        contentBase: path.resolve(__dirname, 'dist'),
        inline: true,
        port: 8082,
        historyApiFallback: true
    }
});